﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MsTestUtilities.RowTests;

namespace MsTestUtilitiesTests.RowTests
{
    [TestClass]
    public class AddRowTests

    {
        [TestMethod]
        public void TestMethod1()
        {
            var tester = new TestScenarioBuilder<int, int, string>();

            tester
                .For(Add)
                .Given(2, 2).Expect("0").Because("When the numbers are equal, the result should be zero")
                .Given(2, 5).Expect("7").Because("When the first number is smaller, it should be the sum")
                .Given(5, 2).Expect("-7").Because("When the first number is bigger, the result should be the negative sum.")
                .Given(100, 2).ExpectNull().Because("When the difference is more than 50 the result should be null.")                
                .Evaluate();
        }

        private string Add(int a, int b)
        {
            if (a == b)
            {
                return "0";
            }

            if (Math.Abs(a-b)> 50)
            {
                return null;
            }

            var prefix = a > b ? "-" : string.Empty;

            return prefix + (a+b).ToString();
        }
    }
}
